package apiPractice;

import practice1.string.ValueOf;

import java.util.*;

public class Test02 {
    public static void main(String[] args) {
        //编写程序，使用String类和StringBuffer类的方法，
        //实现将两个字符串大小写转换后连接到一起，再将连接后的字符串倒序输出。
        //例如 “PersoN”“peOple”，连接成“pERSOnPWoPLE”，再逆序输出“ELPoEPnOSREp
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入第一个字符串");
        String s = scan.nextLine();
        System.out.println("输入第二个字符串");
        String s1 = scan.nextLine();
        String s2 = s + s1;//将输入的两个字符串相加




       /* char[] chs = s2.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < chs.length; i++) {
            if (chs[i] >= 'A' && chs[i] <= 'Z') {
                sb.append((String.valueOf(chs[i])).toLowerCase());
            }
            if (chs[i] >= 'a' && chs[i] <= 'z') {
                sb.append((String.valueOf(chs[i])).toUpperCase());
            }
        }
        System.out.println(sb);
        StringBuilder builder = new StringBuilder();
        for (int i = sb.length() - 1; i >= 0; i--) {
            builder.append(sb.charAt(i));
        }
        System.out.println(builder);
*/   //方法2




        /*String s4 = "";
        StringBuilder builder = new StringBuilder(s4);//将s4的空字符串放到SB里用于字符串的加减
        for (int i = 0; i < s2.length(); i++) {//字符串内部是字符串数组
            if (s2.charAt(i) >= 'A' && s2.charAt(i) <= 'Z') {//判断第i个字符是否是大写
                char z = s2.charAt(i);//
                String s3 = String.valueOf(z);//将字符i转换为字符串
                String s5 = s3.toLowerCase();//将字符串i转换为小写
                builder.append(s5);//
            } else if (s2.charAt(i) >= 'a' && s2.charAt(i) <= 'z') {
                char x = s2.charAt(i);
                String s3 = String.valueOf(x);
                String s6 = s3.toUpperCase();
                builder.append(s6);
            }
        }
        System.out.println(builder);//输出builder

        String s6 = "";//创建一个新的数组存储倒着输出的builder
        StringBuilder bu = new StringBuilder(s6);
        for (int i = builder.length() - 1; i >= 0; i--) {//将字符串倒着遍历
            char y = builder.charAt(i);
            String s7 =String.valueOf(y);
            bu.append(s7);
        }
        System.out.println(bu);*/ //方法1
    }
}
